//实现一个简单的控制台版用户登陆程序, 程序启动提示用户输入用户名密码. 如果用户名密码出错, 使用自定义异常的方式来处理

class User{
    String userName;
    String passWord;

    public User(String userName, String passWord) {
        this.userName = userName;
        this.passWord = passWord;
    }
}
public class LogIn {
    String userName = "Admin";
    String passWord = "123456";
    public void LogIn(String userName,String passWord) throws UserNameException,PasswordException{
        if (!this.userName.equals(userName)){
            throw new UserNameException(userName+"用户名错误！");
        }
        if (!this.passWord.equals(passWord)){
            throw new PasswordException(passWord+"密码错误！");
        }
        System.out.println("登录成功！");
    }
    public static void main(String[] args) {
        LogIn logIn = new LogIn();

        try {
            logIn.LogIn("Admin","1234567");
        }catch (UserNameException e){
            e.printStackTrace();
        }catch (PasswordException e){
            e.printStackTrace();
        }
    }
}
